package com.xcc.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.xcc.model.BaseModel;
import com.xcc.model.Page;
import com.xcc.model.UpdateModel;
import com.xcc.service.BaseServiceImp;


@RestController
public abstract class BaseController<T extends BaseServiceImp,M extends BaseModel> {



	@Autowired
	T mBaseService;
	
	
	//分页查询
	@RequestMapping(value ="/getMember")
	public  Object getMember(Page mPage) {
		return mBaseService.getMember(mPage);
	}


	//模糊查询
	@RequestMapping(value ="/selectName")
	public  Object selectName(@RequestBody UpdateModel<M> mBookMagament) {
		return mBaseService.selectName(mBookMagament);
	}

	//新增
	@RequestMapping(value ="/add", method = RequestMethod.POST)
	public Object addbook(@RequestBody UpdateModel<M> mAddModel) {
		mBaseService.add(mAddModel);
		return mBaseService.getMember(mAddModel.getmPage());
	}

	//删除
	@RequestMapping(value ="/deleteByPrimaryKey", method = RequestMethod.POST)
	public Object deleteByPrimaryKey(@RequestBody UpdateModel<M> mAddModel) {
		return mBaseService.deleteByPrimaryKey(mAddModel);
	}

	//更新
	@RequestMapping(value ="/updateByPrimaryKeySelective", method = RequestMethod.POST)
	public Object updateByPrimaryKeySelective(@RequestBody UpdateModel<M> mAddModel) {
		return mBaseService.updateByPrimaryKeySelective(mAddModel);
	}


/*
	@RequestMapping(value ="/getUserMember")
	public abstract Object getUserMember(Page mPage) ;
*/

	@RequestMapping(value ="/insertSelective", method = RequestMethod.POST)
	public  Object addObjects(@RequestBody M  mListObjects) {
		return mBaseService.insertSelective(mListObjects);
	}



}
